package bpm.domain.document;

import java.io.Serializable;
import java.util.Date;

/**
 * 
 * @author <a mailto="hwangsyin@gmail.com">King</a>
 *
 */
public class DocumentDefinitionView implements Serializable {
	private static final long serialVersionUID = 1L;
	
	public Integer id;
	public String name;
	public Integer categoryId;
	public String categoryName;
	public Integer rank;
	public Integer editTemplateId;
	public String editTemplateName;
	public Integer editTemplateVersion;
	public Integer printTemplateId;
	public String printTemplateName;
	public Integer printTemplateVersion;
	public String processId;
	public String processName;
	public boolean enable;
	public String description;
	
	public String creatorId;
	public String creatorName;
	public Date createTime;
	public Date lastUpdateTime;
	
	public DocumentDefinitionView() {}
	public DocumentDefinitionView(DocumentDefinition dd) {
		if(dd != null) {
			this.id = dd.getId();
			this.name = dd.getName();
			if(dd.getCategory() != null) {
				this.categoryId = dd.getCategory().getId();
				this.categoryName = dd.getCategory().getName();
			}
			this.rank = dd.getRank();
			if(dd.getEditTemplate() != null) {
				this.editTemplateId = dd.getEditTemplate().getId();
				this.editTemplateName = dd.getEditTemplate().getName();
				this.editTemplateVersion = dd.getEditTemplate().getVersion();
			}
			if(dd.getPrintTemplate() != null) {
				this.printTemplateId = dd.getPrintTemplate().getId();
				this.printTemplateName = dd.getPrintTemplate().getName();
				this.printTemplateVersion = dd.getPrintTemplate().getVersion();
			}
			if(dd.getProcessDefinition() != null) {
				this.processId = dd.getProcessDefinition().getId();
				this.processName = dd.getProcessDefinition().getName();
			}
			this.enable = dd.isEnable();
			this.description = dd.getDescription();
			if(dd.getCreator() != null) {
				this.creatorId = dd.getCreator().getId();
				this.creatorName = dd.getCreator().getName();
			}
			this.createTime = dd.getCreateTime();
			this.lastUpdateTime = dd.getLastUpdateTime();
		}
	}
}
